package com.boo2.entity;

/**
 * @author wzm
 * @create 2024-02-27 11:37
 * project_name:JavaWeb2401
 * @Description
 */
//专门用来返回统一结果信息的类
public class Result {
    private Integer code;//响应状态码 0 失败  1成功
    private String msg;//返回给前端的提示信息
    private Object data;//返回给前端携带的数据

    public Result() {
    }

    public Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    //写两个静态方法 把成功和失败的方法直接定义好 调用就行不用赋值
    //成功=
    public static Result ok(){
        return new Result(1,"成功",null);
    }

    public static Result ok(Object o){
        return new Result(1,"成功",o);
    }

    public static Result noOk(String msg){
        return new Result(0,msg,null);
    }
}


